/* Copyright (c) [2020] [ylc]. Licensed under Apache-2.0 License. */

#include "mcu_it.h"
#include "my_timer.h"

//定时器周期中断 1ms
void Timer_Handler(void)		//interrupt 1	//51单片机这里根据手册填中断线
{
	if(++mTimer.ticks_num_1ms>=10){						//10ms
		mTimer.ticks_num_1ms=0;
		mTimer.flags.ticks_10ms=1;
		if(++mTimer.ticks_num_10ms>=10){				//100ms
			mTimer.ticks_num_10ms=0;
			mTimer.flags.ticks_100ms=1;
			if(++mTimer.ticks_num_100ms>=10){			//1s
				mTimer.ticks_num_100ms=0;
				mTimer.flags.ticks_1s=1;
				if(++mTimer.ticks_num_1s>=60){			//1min
					mTimer.ticks_num_1s=0;
					mTimer.flags.ticks_1min=1;
					if(++mTimer.ticks_num_1min>=60){	//1h
						mTimer.ticks_num_1min=0;
						mTimer.flags.ticks_1h=1;
						if(++mTimer.ticks_num_1h>=24){	//1day
							mTimer.ticks_num_1h=0;
							mTimer.flags.ticks_1day=1;
							
						}
					}
				}
			}
		}
	}
	else{
		if(mTimer.ticks_num_1ms==1){
			mTimer.flags.ticks_10ms1=1;
		}
		if(mTimer.ticks_num_1ms==2){
			mTimer.flags.ticks_10ms2=1;
		}	
		if(mTimer.ticks_num_1ms==3){
			mTimer.flags.ticks_10ms3=1;	
		}	
	}
}






